package org.ronghao.androidwifiplatfrom.entity;

import org.json.JSONException;
import org.json.JSONObject;
import org.ronghao.androidwifiplatfrom.utils.Contants;

public class User {
	private String name = "";// 名称
	private int style = 1;// 样式
	private int pic = 1;// 头像
	private String ip = "127.0.0.1";// IP 地址

	public User() {
	}

	public User(String msg) {
		try {
			JSONObject jsonObject = new JSONObject(msg);
			name = jsonObject.getString(Contants.COMMUNICATION_USER_NAME);
			style = jsonObject.getInt(Contants.COMMUNICATION_USER_STYLE);
			pic = jsonObject.getInt(Contants.COMMUNICATION_USER_PIC);
			ip = jsonObject.getString(Contants.COMMUNICATION_USER_IP);
		} catch (JSONException e) {
			name = "";
			style = 1;
			pic = 1;
			ip = "127.0.0.1";
		}
	}

	public String userToString() {
		return Contants.objToJsonString(this);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getStyle() {
		return style;
	}

	public void setStyle(int style) {
		this.style = style;
	}

	public int getPic() {
		return pic;
	}

	public void setPic(int pic) {
		this.pic = pic;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}
}
